package com.zjdiepu.www.base.core;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import java.io.Serializable;
import java.math.BigDecimal;

import javax.validation.GroupSequence;
import javax.validation.constraints.Null;

import com.zjdiepu.www.base.annotation.Add;
import com.zjdiepu.www.base.annotation.Id;
import com.zjdiepu.www.base.annotation.Update;
import com.zjdiepu.www.base.enums.status.DpStatus;
import com.zjdiepu.www.base.enums.type.TypeData;
import com.zjdiepu.www.common.util.UUIDFactory;
/**
 * 公共属性
 * @author xiongxiaotun
 * @date 2017年3月22日 下午1:05:21
 * @since v1.0.0
 * @update
 */
@ApiModel(value="BaseModel", description="对象公共属性",parent=ParentModel.class)
@GroupSequence({Id.class, Update.class, Add.class, BaseModel.class})
public class BaseModel extends ParentModel implements Serializable {
	
	private static final long serialVersionUID = 1L;
	/**
	 * 排序字段
	 */
//	@Null(message="不能篡改排序",groups={Id.class, Update.class})
	@ApiModelProperty(name="sortValue",required=false,value="排序", example="0", hidden=true)
	private Integer sortValue;
	/**
	 * 创建人
	 */
	@Null(message="不能篡改创建人",groups={Id.class, Update.class})
	@ApiModelProperty(name="creator",required=false,value="创建人", hidden=true)
	private String creator;
	/**
	 * 创建人名称
	 */
	@Null(message="不能篡改创建名称",groups={Id.class, Update.class})
	@ApiModelProperty(name="creatorName",required=false,value="创建人名称", hidden=true)
	private String creatorName;
	/**
	 * 创建时间
	 */
	@Null(message="不能篡改创建时间",groups={Id.class, Update.class})
	@ApiModelProperty(name="created",required=false,value="创建时间", hidden=true)
	private Integer created;
	/**
	 * 修改人
	 */
	@Null(message="不能篡改修改人",groups={Id.class, Update.class})
	@ApiModelProperty(name="modifier",required=false,value="修改人", hidden=true)
	private String modifier;
	/**
	 * 修改人名称
	 */
	@Null(message="不能篡修改人名称",groups={Id.class, Update.class})
	@ApiModelProperty(name="modifierName",required=false,value="修改人名称", hidden=true)
	private String modifierName;
	/**
	 * 最近修改时间
	 */
	@Null(message="不能篡改最近修改时间",groups={Id.class, Update.class})
	@ApiModelProperty(name="modified",required=false,value="最近修改时间", hidden=true)
	private Integer modified;
	/**
	 * 数据状态
	 * {@link DpStatus}
	 */
	@Null(message="不能篡改数据状态",groups={Id.class, Update.class, Add.class})
	@ApiModelProperty(name="dpStatus",required=false,value="数据状态", example="1", hidden=true)
	private Integer dpStatus;
	
	/**
	 * 基本查询条件
	 */
	@Null(message="不能篡改控制字段",groups={Id.class, Update.class, Add.class})
	@ApiModelProperty(name="notDeleted",required=false,value="没有删除", hidden=true)
	private Boolean notDeleted;
	
	/**
	 * 备注
	 */
	@ApiModelProperty(name="remarks",required=false,value="备注",example="备注信息...")
	private String remarks;
	
	/**
	 * 备用字段1
	 */
	@ApiModelProperty(name="ccol1",required=false,value="备用字段1",example="备用字段1", hidden=true)
	private String ccol1;
	
	/**
	 * 备用字段2
	 */
	@ApiModelProperty(name="ccol2",required=false,value="备用字段2",example="备用字段2", hidden=true)
	private String ccol2;
	
	/**
	 * 备用字段3
	 */
	@ApiModelProperty(name="ccol3",required=false,value="备用字段3",example="备用字段3", hidden=true)
	private String ccol3;
	
	/**
	 * 备用字段4
	 */
	@ApiModelProperty(name="dcol1",required=false,value="备用字段4",example="1234", hidden=true)
	private BigDecimal dcol1;
	
	/**
	 * 备用字段5
	 */
	@ApiModelProperty(name="dcol2",required=false,value="备用字段5",example="1234", hidden=true)
	private BigDecimal dcol2;
	
	/**
	 * 数据类型:1.系统生成 2.导入数据
	 */
	@ApiModelProperty(name="typeData",required=false,value="备用字段5",example="1234")
	private Integer typeData;
	
	/**
	 * 数据状态显示
	 * {@link DpStatus}
	 */
	@ApiModelProperty(name="dpStatusDisplay",required=false,value="数据状态显示", example="禁用", hidden=true)
	private String dpStatusDisplay;
	/**
	 * 排序
	 */
	@ApiModelProperty(name="orderSql",required=false,value="排序", example="排序", hidden=true)
	private String orderSql;
	
	/**
	 * 站内信接收人
	 */
	@ApiModelProperty(name="receiverIds",required=false,value="站内信接收人", example="站内信接收人", hidden=true)
	private String receiverIds;
	/**
	 * @author xiongxiaotun <br/>
	 * @Title: notDeleted  <br/>
	 * @Description: 未删除的数据 <br/>
	 * @version V1.0  <br/>
	 */
	public void notDeleted(){
		this.notDeleted = true;
	}
	
	/**
	 * @author xiongxiaotun <br/>
	 * @Title: initInsertData  <br/>
	 * @Description: 初始化数据：添加 <br/>
	 * @param userId
	 * @param creatorName
	 * @version V1.0  <br/>
	 */
    public void initInsertData(String userId,String creatorName) {
        Integer current = (int)(System.currentTimeMillis() / 1000);
        setId(UUIDFactory.getUUID());
        setCreator(userId);
        setCreatorName(creatorName);
        setCreated(current);
        setModifier(userId);
        setModifierName(creatorName);
        setModified(current);
        setDpStatus(DpStatus.NORMAL.getCode());
        setTypeData(TypeData.SYSTEM.getCode());
    }

    /**
     * @author xiongxiaotun <br/>
     * @Title: initUpdateData  <br/>
     * @Description: 初始化数据：更新 <br/>
     * @param userId
     * @param modifierName
     * @version V1.0  <br/>
     */
    public void initUpdateData(String userId,String modifierName) {
    	setModifier(userId);
    	setModifierName(modifierName);
        setModified((int)(System.currentTimeMillis() / 1000));
    }
    
    /**
     * @author xiongxiaotun <br/>
     * @Title: initDeleteData  <br/>
     * @Description: 初始化数据：删除  <br/>
     * @param userId
     * @param modifierName
     * @version V1.0  <br/>
     */
    public void initDeleteData(String userId,String modifierName) {
    	setModifier(userId);
    	setModifierName(modifierName);
        setModified((int)(System.currentTimeMillis() / 1000));
        setDpStatus(DpStatus.DELETED.getCode());
    }

	public Integer getSortValue() {
		return sortValue;
	}

	public void setSortValue(Integer sortValue) {
		this.sortValue = sortValue;
	}

	public String getCreator() {
		return creator;
	}

	public void setCreator(String creator) {
		this.creator = creator;
	}

	public String getCreatorName() {
		return creatorName;
	}

	public void setCreatorName(String creatorName) {
		this.creatorName = creatorName;
	}


	public String getModifier() {
		return modifier;
	}

	public void setModifier(String modifier) {
		this.modifier = modifier;
	}

	public String getModifierName() {
		return modifierName;
	}

	public void setModifierName(String modifierName) {
		this.modifierName = modifierName;
	}


	public Integer getDpStatus() {
		return dpStatus;
	}

	public void setDpStatus(Integer dpStatus) {
		this.dpStatus = dpStatus;
	}
	
	public Integer getCreated() {
		return created;
	}

	public void setCreated(Integer created) {
		this.created = created;
	}

	public Integer getModified() {
		return modified;
	}

	public void setModified(Integer modified) {
		this.modified = modified;
	}

	public Boolean getNotDeleted() {
		return notDeleted;
	}

	public void setNotDeleted(Boolean notDeleted) {
		this.notDeleted = notDeleted;
	}
	
	public String getRemarks() {
		return remarks;
	}

	public void setRemarks(String remarks) {
		this.remarks = remarks;
	}

	public String getCcol1() {
		return ccol1;
	}

	public void setCcol1(String ccol1) {
		this.ccol1 = ccol1;
	}

	public String getCcol2() {
		return ccol2;
	}

	public void setCcol2(String ccol2) {
		this.ccol2 = ccol2;
	}

	public String getCcol3() {
		return ccol3;
	}

	public void setCcol3(String ccol3) {
		this.ccol3 = ccol3;
	}

	public BigDecimal getDcol1() {
		return dcol1;
	}

	public void setDcol1(BigDecimal dcol1) {
		this.dcol1 = dcol1;
	}

	public BigDecimal getDcol2() {
		return dcol2;
	}

	public void setDcol2(BigDecimal dcol2) {
		this.dcol2 = dcol2;
	}

	public Integer getTypeData() {
		return typeData;
	}

	public void setTypeData(Integer typeData) {
		this.typeData = typeData;
	}

	public String getDpStatusDisplay() {
		return dpStatusDisplay;
	}

	public void setDpStatusDisplay(String dpStatusDisplay) {
		this.dpStatusDisplay = dpStatusDisplay;
	}

	public String getOrderSql() {
		return orderSql;
	}

	public void setOrderSql(String orderSql) {
		this.orderSql = orderSql;
	}

	public String getReceiverIds() {
		return receiverIds;
	}

	public void setReceiverIds(String receiverIds) {
		this.receiverIds = receiverIds;
	}
}
